package cn.highedu.spring03.entity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnBean(Worker.class) // 如果Worker类的对象存在 创建斧子对象
@ConditionalOnMissingBean(name = "saw") // 如果没有saw对象 就创建axe对象
public class Axe implements Tool {
    Logger logger = LoggerFactory.getLogger(Axe.class);
    public Axe() {
        logger.info("创建斧子");
    }

    @Override
    public String toString() {
        return "斧子";
    }
}
